 <?php
					
include 'conn.php';		

$request_body = file_get_contents('php://input');
$data = json_decode($request_body, true);


require '../vendor/autoload.php';



if($_GET['lx']=='GetListData'){
	$page = isset($data['page']) ? intval($data['page']) : 1;
	$rows = isset($data['size']) ? intval($data['size']) : 10;
	$offset = ($page-1)*$rows;
	
	$sort = isset($data['sort']) ? strval($data['sort']) : 'id';
	$order = isset($data['order']) ? strval($data['order']) : 'desc';
	
	$name = isset($data['Find']['name']) ? $data['Find']['name'] : '';
	$zd = isset($data['Find']['zd']) ? $data['Find']['zd'] : '';
	$nr = isset($data['Find']['nr']) ? $data['Find']['nr'] : '';

	$where = "action like '%$name%' and ".$zd." like '%$nr%'";
	$sql="select * from log where ".$where." order by $sort $order limit $offset,$rows";
	
	$rows = array();
	$rs =  mysqli_query($con,$sql);
	while($row = $rs->fetch_assoc()){
		array_push($rows,$row);
	} 

	$rs = mysqli_query($con,"select count(*) as num from log where ".$where." ");
	$row = $rs->fetch_assoc();
	$result["total"] = $row["num"];
	

	// $token = $_SERVER['HTTP_AUTHORIZATION'];
	// $token=str_replace("Bearer ","",$token);
	// $str=verifyToken($token);
	// $exp=$str->exp;
	 
	//verifyToken1($token);

	$result["code"] = 200;
	$result["data"] = $rows;
	$result["message"] = "list";
	$result["sql"] = $sql;
	echo json_encode($result);	

	rlog('list');

}elseif($_GET['lx']=='getSelect'){
	

	
}else{

	$result["code"] = 201;
	$result["message"] = "201";
	echo json_encode($result);
	
}


?>